<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
const kStyle = [
    '<style>',
    '#target {',
        'direction: rtl;',
        'font-family: Lucida Grande;',
        'font-size: 40px;',
        'width: 200px',
    '}',
    '</style>',
].join('');

// Soft line wrap at \u05D9
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            '|before \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'b|efore \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '1');
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            'b|efore \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'be|fore \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '2');
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            'be|fore \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'bef|ore \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '3');
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            'bef|ore \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'befo|re \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '4');
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            'befo|re \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'befor|e \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '5');
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            'befor|e \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'before| \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '6');
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            'before| \u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'before |\u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '7');
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            'before |\u05d0\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'before \u05d0|\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '8');
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            'before \u05d0|\u05d7\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'before \u05d0\u05d7|\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '9');
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            'before \u05d0\u05d7|\u05e8\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'before \u05d0\u05d7\u05e8|\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '10');
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            'before \u05d0\u05d7\u05e8|\u05d9 \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'before \u05d0\u05d7\u05e8\u05d9| \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '11');
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            'before \u05d0\u05d7\u05e8\u05d9| \u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'before \u05d0\u05d7\u05e8\u05d9 |\u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '12');
selection_test(
    [
        kStyle,
        '<div contenteditable id="target">',
            'before \u05d0\u05d7\u05e8\u05d9 |\u05d0\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ],
    selection => selection.modify('move', 'forward', 'character'),
    [
        kStyle,
        '<div contenteditable id="target">',
            'before \u05d0\u05d7\u05e8\u05d9 \u05d0|\u05e0\u05e6\u05d9\u05e7\u05dc\u05d5\u05e4\u05d3\u05d9\u05d4',
        '</div>',
    ], '13');
</script>
